package com.devgear.codesizer.model;

// Generated 24-oct-2011 0:54:57 by Hibernate Tools 3.4.0.CR1

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Role generated by hbm2java
 */
@Entity
@Table(name = "roles", schema = "public")
public class Role implements java.io.Serializable {

	private int idRole;
	private Role role;
	private Client client;
	private String name;
	private Set<Group> groups = new HashSet<Group>(0);
	private Set<User> users = new HashSet<User>(0);
	private Set<Role> roles = new HashSet<Role>(0);

	public Role() {
	}

	public Role(int idRole, Role role, Client client) {
		this.idRole = idRole;
		this.role = role;
		this.client = client;
	}

	public Role(int idRole, Role role, Client client, String name,
			Set<Group> groups, Set<User> users, Set<Role> roles) {
		this.idRole = idRole;
		this.role = role;
		this.client = client;
		this.name = name;
		this.groups = groups;
		this.users = users;
		this.roles = roles;
	}

	@Id
	@Column(name = "id_role", unique = true, nullable = false)
	public int getIdRole() {
		return this.idRole;
	}

	public void setIdRole(int idRole) {
		this.idRole = idRole;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_super_role", nullable = false)
	public Role getRole() {
		return this.role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "id_client", nullable = false)
	public Client getClient() {
		return this.client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	@Column(name = "name", length = 50)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
	public Set<Group> getGroups() {
		return this.groups;
	}

	public void setGroups(Set<Group> groups) {
		this.groups = groups;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "roles_users", schema = "public", joinColumns = { @JoinColumn(name = "id_role", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "id_user", nullable = false, updatable = false) })
	public Set<User> getUsers() {
		return this.users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "role")
	public Set<Role> getRoles() {
		return this.roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

}
